\subsection{Motivation}
Let \( U \) be open, and \( \gamma \) be a closed curve in \( U \) homologous to zero in \( U \).
Then, if \( f \colon U \to \mathbb C \) is holomorphic, we have Cauchy's integral formula
\[
	\int_\gamma \underbrace{\frac{f(z) \dd{z}}{z-a}}_{g(z) \dd{z}} = 2 \pi i \cdot I(\gamma;a) f(a)
\]
for all \( a \in U \setminus \Im \gamma \).
This allows us to compute \( \int_\gamma g(z) \dd{z} \) for a holomorphic function \( g \colon U \setminus \qty{a} \to \mathbb C \) where \( \gamma \) does not pass through the point \( a \), provided that \( g \) satisfies a particular condition: \( (z-a) g(z) \) is the restriction to \( U \setminus \qty{a} \) of a holomorphic function \( f \colon U \to \mathbb C \).
We wish to drop this restriction and observe the consequences; that is, we wish to compute \( \int_\gamma g(z) \dd{z} \) for arbitrary holomorphic functions \( g \colon U \setminus \qty{a} \to \mathbb C \) for \( a \in U \) and \( a \not\in \Im \gamma \).
For example, consider \( g(z) = e^{z^{-1}} \) for \( U = \mathbb C \) and \( a = 0 \), \( \gamma = \partial D(0,1) \).
Note that \( zg(z) = ze^{z^{-1}} \) is not continuous at \( z = 0 \), so it is certainly not holomorphic.
This leads us to the study of singularities, and to eventually prove the residue theorem.

\subsection{Removable singularities}
\begin{definition}
	Let \( U \subseteq \mathbb C \) be open.
	If \( a \in U \) and \( f \colon U \setminus \qty{a} \to \mathbb C \) is holomorphic, we say that \( f \) has an \textit{isolated singularity} at \( a \).
\end{definition}
\begin{definition}
	An isolated singularity \( a \) of \( f \) is a \textit{removable singularity} if \( f \) can be defined at \( a \) such that the extended function is holomorphic on \( U \).
\end{definition}
\begin{proposition}
	Let \( U \) be open, \( a \in U \), and \( f \colon U \setminus \qty{a} \to \mathbb C \) be holomorphic.
	Then, the following are equivalent.
	\begin{enumerate}
		\item \( f \) has a removable singularity at \( a \);
		\item \( \lim_{z \to a} f(z) \) exists in \( \mathbb C \);
		\item there exists \( D(a,\varepsilon) \subseteq U \) such that \( \abs{f(z)} \) is bounded in \( D(a,\varepsilon) \setminus \qty{a} \);
		\item \( \lim_{z \to a} (z-a) f(z) = 0 \).
	\end{enumerate}
\end{proposition}
\begin{proof}
	We can see that (i) implies (ii).
	If \( a \) is a removable singularity of \( f \), then by definition there is a holomorphic function \( g \colon U \to \mathbb C \) such that \( f(z) = g(z) \) for all \( z \in U \setminus \qty{a} \).
	Then \( \lim_{z \to a} f(z) = \lim_{z \to a} g(z) = g(a) \in \mathbb C \).
	Similarly, (ii) implies (iii) and (iii) implies (iv) are clear.

	It suffices to check (iv) implies (i).
	Consider the function
	\[
		h(z) = \begin{cases}
			(z-a)^2 f(z) & \text{if } z \neq a \\
			0            & \text{if } z = a
		\end{cases}
	\]
	We have
	\[
		\lim_{z \to a} \frac{h(z) - h(a)}{z-a} = \lim_{z \to a} (z-a) f(z) = 0
	\]
	Hence \( h \) is differentiable at \( a \) with \( h'(a) = 0 \).
	Since \( h \) is differentiable in \( U \setminus \qty{a} \), we must have that \( h \) is holomorphic in \( U \).
	Since \( h(a) = h'(a) = 0 \), we can find \( r > 0 \) and a holomorphic \( g \colon D(a,r) \to \mathbb C \) such that \( h(z) = (z-a)^2 g(z) \) for \( z \in D(a,r) \).
	Comparing this to the definition of \( h \), we have that \( f(z) = g(z) \) for \( D(a,r) \setminus \qty{a} \).
	By defining \( f(a) = g(a) \), we have that \( f \) is differentiable at \( a \) with \( f'(a) = g'(a) \).
	So \( a \) is a removable singularity of \( f \).
\end{proof}
\begin{example}
	Consider \( f(z) = \frac{e^z - 1}{z} \).
	Certainly \( f \) is holomorphic on \( \mathbb C \setminus \qty{0} \), and \( \lim_{z \to 0} zf(z) = 0 \).
	So \( z = 0 \) is a removable singularity.
	We can also see directly by the Taylor series of \( e^z \) at \( z = 0 \) that \( f(z) = \sum_{k=1}^\infty \frac{z^{k-1}}{k!} \) for \( z \neq 0 \), and the series on the right hand side defines an entire function.
\end{example}
\begin{remark}
	If \( u \colon D(0,1) \setminus \qty{0} \to \mathbb R \) is a \( C^2 \) harmonic function, when can we say that \( z = 0 \) is a removable singularity, i.e.\ that \( u \) extends to \( z = 0 \) as a harmonic function?
	We can relate this to the study of holomorphic functions.
	However, unlike with previous cases, the analogy is more subtle in this case.
	We cannot necessarily construct a harmonic conjugate \( v \) such that \( u + iv \) is holomorphic in \( D(0,1) \setminus\qty{0} \), because \( U \) is not simply connected.

	There is a similar result, however.
	If \( \lim_{z \to 0} u(z) \) exists, then the extended function is in fact \( C^2 \) and harmonic.
	More generally, if \( u \) is bounded near \( z = 0 \), there exists a harmonic extension.
	We can also consider the case \( \lim_{z \to 0} \abs{z} \abs{u(z)} = 0 \); this is explored on the example sheets.
\end{remark}

\subsection{Poles}
Note, if a holomorphic function \( f \) has a non-removable singularity, \( f \) is not bounded in \( D(a,r) \setminus \qty{a} \) for any \( r > 0 \).
\begin{definition}
	If \( a \in U \) is an isolated singularity of \( f \), then \( a \) is a \textit{pole} of \( f \) if
	\[
		\lim_{z \to a} \abs{f(z)} = \infty
	\]
\end{definition}
\begin{example}
	\( f(z) = (z-a)^{-k} \) for \( k \in \mathbb N \) has a pole at \( a \).
\end{example}
\begin{definition}
	If \( a \in U \) is an isolated singularity of \( f \) that is not removable or a pole, it is an \textit{essential singularity}.
\end{definition}
\begin{remark}
	An equivalent characterisation for \( a \) to be an essential singularity is that the limit \( \lim_{z \to a} \abs{f(z)} \) does not exist.
	This follows from the previous proposition and the definition of a pole.
\end{remark}
\begin{example}
	\( f(z) = e^{\frac{1}{z}} \) has \( \abs{f(iy)} = 1 \) for all \( y \in \mathbb R \setminus \qty{0} \) and \( \lim_{x \to 0^+} f(x) = \infty \).
	So \( z = 0 \) is an essential singularity of \( f \).
\end{example}
\begin{proposition}
	Let \( f \colon U \setminus \qty{a} \to \mathbb C \) be holomorphic.
	The following are equivalent.
	\begin{enumerate}
		\item \( f \) has a pole at \( a \);
		\item there exists \( \varepsilon > 0 \) and a holomorphic function \( h \colon D(a,\varepsilon) \to \mathbb C \) with \( h(a) = 0 \) and \( h(z) \neq 0 \) for all \( z \neq a \) such that \( f(z) = \frac{1}{h(z)} \) for \( z \in D(a,\varepsilon) \setminus \qty{a} \);
		\item there exists a unique integer \( k \geq 1 \) and a unique holomorphic function \( g \colon U \to \mathbb C \) with \( g(a) \neq 0 \) such that \( f(z) = (z-a)^{-k} g(z) \) for \( z \in U \setminus \qty{a} \).
	\end{enumerate}
\end{proposition}
\begin{remark}
	Since (i) implies (iii), there exists no holomorphic function on a punctured disc \( f \colon D(a,R) \setminus \qty{a} \to \mathbb C \) such that \( \abs{f(z)} \to \infty \) as \( z \to a \) at the rate of a negative non-integer power of \( \abs{z-a} \), i.e.\ with \( c\abs{z-a}^{-s} \leq \abs{f(z)} \leq C\abs{z-a}^{-s} \) for some constants \( s \in (0,\infty) \setminus \mathbb N \), \( c > 0 \), \( C > 0 \), and all \( z \in D(a,R) \setminus \qty{a} \).
\end{remark}
\begin{proof}
	We show (i) implies (ii).
	Since \( \lim_{z \to a} \abs{f(z)} = \infty \), there exists \( \varepsilon > 0 \) such that \( \abs{f(z)} \geq 1 \) for all \( 0 < \abs{z-a} < \varepsilon \).
	Hence \( \frac{1}{f(z)} \) is holomorphic and bounded in \( D(a,\varepsilon) \setminus \qty{a} \).
	By the above proposition, \( \frac{1}{f} \) has a removable singularity at \( a \), so there exists a holomorphic function \( h \colon D(a,\varepsilon) \to \mathbb C \) such that \( \frac{1}{f} = h \), or equivalently, \( f = \frac{1}{h} \), for \( z \in D(a,\varepsilon) \setminus \qty{a} \).
	Since \( \abs{f(z)} \to \infty \) as \( z \to a \), we have that \( h(a) = 0 \).

	Now we show (ii) implies (iii).
	Let \( \varepsilon \) and \( h \) be as in the definition of (ii).
	By Taylor series, there exists \( k \geq 1 \) and a holomorphic function \( h_1 \colon D(a,\varepsilon) \to \mathbb C \) with \( h_1(z) \neq 0 \) for all \( z \in D(a,\varepsilon) \) such that \( h(z) = (z-a)^k h_1(z) \).
	If \( g_1 = \frac{1}{h_1} \), then \( g_1 \) is holomorphic in \( D(a,\varepsilon) \), \( g_1 \neq 0 \) in \( D(a,\varepsilon) \), and \( f(z) = (z-a)^{-k} g_1(z) \) in \( D(a,\varepsilon) \setminus \qty{a} \).

	We can now define \( g \colon U \to \mathbb C \) by \( g(z) = g_1(z) \) for \( z \in D(a,\varepsilon) \), and \( g(z) = (z-a)^k f(z) \) for \( z \in U \setminus \qty{a} \).
	Since \( f(z) = (z-a)^{-k} g_1(z) \), the definitions agree on \( D(a,\varepsilon) \setminus \qty{a} \), so \( g \) is well-defined and holomorphic in \( U \), and \( g(a) = g_1(a) \neq 0 \).
	This proves the existence of an integer \( k \geq 1 \) and a holomorphic \( g \colon U \to \mathbb C \) with \( g(a) \neq 0 \) such that \( f(z) = (z-a)^{-k} g(z) \) for all \( z \in U \setminus \qty{a} \).

	To prove uniqueness of \( k \) and \( g \), suppose there exists \( \widetilde k \geq 1 \) and a holomorphic \( \widetilde g \colon U \to \mathbb C \) with \( \widetilde g(a) \neq 0 \) such that \( f(z) = (z-a)^{-\widetilde k} \widetilde g(z) \) for all \( z \in U \setminus \qty{a} \).
	Then we have \( g(z) = (z-a)^{k - \widetilde k} \widetilde g(z) \) for \( z \in U \setminus \qty{a} \).
	Since \( g, \widetilde g \) are holomorphic with \( g(a) \neq 0 \) and \( \widetilde g(a) \neq 0 \), this can only be true if \( k = \widetilde k \), and hence \( g = \widetilde g \) on \( U \setminus \qty{a} \), and then at \( a \) by continuity.

	It is clear that (iii) implies (i).
\end{proof}
\begin{definition}
	If \( f \) has a pole at \( z = a \), then the unique positive integer \( k \) given by the above proposition is the \textit{order} of the pole at \( a \).
	If \( k = 1 \), we say that \( f \) has a \textit{simple pole} at \( a \).

	Let \( U \) be open and \( S \setminus U \) be a discrete subset of \( U \), so all points of \( S \) are isolated.
	If \( f \colon U \setminus S \to \mathbb C \) is holomorphic and each \( a \in S \) is either a removable singularity or a pole of \( f \), then \( f \) is a \textit{meromorphic} function on \( U \).
	In particular, if \( S = \varnothing \), \( f \) is holomorphic.
\end{definition}
\begin{remark}
	If \( f \colon U \setminus \qty{a} \to \mathbb C \) is holomorphic and the singularity \( z = a \) is a pole of \( f \), we can regard \( f \) as a continuous mapping onto the Riemann sphere \( f \colon U \to \mathbb C \cup \qty{\infty} \), by setting \( f(a) = \infty \).
	Here, \( f \) is holomorphic on \( U \).
	Holomorphicity of the extended map near the pole \( a \) follows from the fact that in a punctured disc about \( a \), \( \frac{1}{f} \) has the form \( \frac{(z-a)^k}{g(z)} \) for some holomorphic \( g \) with \( g(z) \neq 0 \) near \( a \); and the fact that any function \( h \) defined in a neighbourhood of \( \infty \) in the Riemann sphere is holomorphic, by definition, if the function \( \widetilde h(z) = h\qty(\frac{1}{z}) \) if \( z \neq 0 \), \( \widetilde h(0) = h(\infty) \) is holomorphic near zero.
	Hence \( h \circ f = \widetilde h \circ \qty(\frac{1}{f}) \) is holomorphic near \( a \) for all holomorphic \( h \) in a neighbourhood of \( \infty \) in the Riemann sphere.

	Hence, any meromorphic function \( f \colon U \setminus S \to \mathbb C \) can be viewed as a holomorphic function \( U \to \mathbb C \cup \qty{\infty} \).
	Geometrically, therefore, poles are not `real' singularities, and the only true isolated singularities are the essential singularities.
	This is explored further in Part II Riemann Surfaces.
\end{remark}

\subsection{Essential singularities}
\begin{remark}
	Suppose \( z = a \) is an essential singularity of a holomorphic \( f \colon U \setminus \qty{a} \to \mathbb C \).
	Then there exists a sequence of points \( a_n \in U \setminus \qty{a} \), \( a_n \to a \), such that \( f(a_n) \to \infty \).
	This is because \( a \) is not removable.
	There is also another sequence of points \( b_n \in U \setminus \qty{a} \), \( b_n \to a \) such that \( (f(b_n)) \) is bounded.
	This is because \( a \) is not a pole.
	We can generalise this further.
\end{remark}
\begin{theorem}[Casorati--Weierstrass theorem]
	If \( f \colon U \setminus \qty{a} \to \mathbb C \) is holomorphic and \( a \in U \) is an essential singularity of \( f \), then for any \( \varepsilon > 0 \), the set \( f(D(a,\varepsilon) \setminus \qty{a}) \) is dense in \( \mathbb C \).
\end{theorem}
The proof is an exercise on the second example sheet.
\begin{theorem}[Picard's theorem]
	If \( f \colon U \setminus \qty{a} \to \mathbb C \) is holomorphic and \( a \in U \) is an essential singularity of \( f \), then there exists \( w \in \mathbb C \) such that for any \( \varepsilon > 0 \), \( \mathbb C \setminus \qty{w} \subseteq f(D(a,\varepsilon) \setminus \qty{a}) \).
	In other words, in any neighbourhood \( D(a,\varepsilon) \setminus \qty{a} \), \( f \) attains all complex numbers except possibly one.
\end{theorem}
The proof is omitted.

\subsection{Laurent series}
If \( z = a \) is a removable singularity of \( f \), then for some \( R > 0 \), \( f \) is given by a power series \( \sum_{n = 0}^\infty c_n(z-a)^n \), which is the Taylor series of the holomorphic extension of \( f \) to \( D(a,R) \), for all \( z \in D(a,R) \setminus \qty{a} \).
If \( a \) is a pole of some order \( k \geq 1 \), then for some \( R > 0 \) we have \( f(z) = (z-a)^{-k} g(z) \) for some holomorphic \( g \colon D(a,R) \to \mathbb C \) and all \( z \in D(a,R) \setminus \qty{a} \), so using the Taylor seires of \( g \), we find a series of the form \( f(z) = \sum_{n=-k}^\infty c_n (z-a)^n \), for \( z \in D(a,R) \setminus \qty{a} \).
When \( a \) is an essential singularity, we can still obtain an analogous series expansion with infinitely many terms with negative powers.
More generally, we have the following.
\begin{theorem}[Laurent expansion]
	Let \( f \) be holomorphic on an annulus
	\[ A = \qty{z \in \mathbb C \colon r < \abs{z-a} < R} \]
	for \( 0 \leq r < R \leq \infty \).
	Then:
	\begin{enumerate}
		\item \( f \) has a unique convergent series expansion
		      \[
			      f(z) = \sum_{n = -\infty}^\infty c_n (z-a)^n \equiv \sum_{n=1}^\infty c_{-n} (z-a)^{-n} + \sum_{n=0}^\infty c_n (z-a)^n
		      \]
		      where the \( c_n \) are constants;
		\item for any \( \rho \in (r,R) \), the coefficient \( c_n \) is given by
		      \[
			      c_n = \frac{1}{2 \pi i} \int_{\partial D(a,\rho)} \frac{f(z) \dd{z}}{(z-a)^{n+1}}
		      \]
		\item if \( r < \rho' \leq \rho < R \), then the two series in (i) separately converge uniformly on the set
		      \[
			      \qty{z \in \mathbb C \colon \rho' \leq \abs{z-a} \leq \rho}
		      \]
	\end{enumerate}
\end{theorem}
\begin{remark}
	If \( f \) is the restriction of \( A \) of a holomorphic function \( g \) on the full disc \( D(a,R) \), then by the formula in part (ii), we have for any negative \( n = -m \), \( m \geq 1 \), the coefficient \( c_{-m} \) is zero by Cauchy's theorem.
	In this case, the Laurent series of \( f \) is the Taylor series of \( g \) restricted to \( A \).
	The new content of the theorem is simply when \( f \) has no holomorphic extension to \( D(a,R) \).
\end{remark}
\begin{proof}
	Let \( w \in A \) and consider the function
	\[
		g(z) = \begin{cases}
			\frac{f(z) - f(w)}{z-w} & \text{if } z \neq w \\
			f'(w)                   & \text{if } z = w
		\end{cases}
	\]
	This \( g \) is continuous in \( A \) and holomorphic in \( A \setminus \qty{w} \).
	Hence, this is holomorphic in \( A \) since this is a removable singularity.
	Let \( \rho_1, \rho_2 \) such that \( r < \rho_1 < \abs{w - a} < \rho_2 < R \).
	The two positively oriented curves \( \partial D(a,\rho_1) \) and \( \partial D(a,\rho_2) \) are homotopic in \( A \).
	Hence,
	\[
		\int_{\partial D(a,\rho_1)} g(z) \dd{z} = \int_{\partial D(a,\rho_2)} g(z) \dd{z}
	\]
	Substituting for \( g \),
	\[
		\int_{\partial D(a,\rho_1)} \frac{f(z) \dd{z}}{z-w} - 2\pi i \cdot I(\partial D(a,\rho_1);w) f(w) = \int_{\partial D(a,\rho_2)} \frac{f(z) \dd{z}}{z-w} - 2\pi i \cdot I(\partial D(a,\rho_2);w) f(w)
	\]
	We have
	\[
		I(\partial D(a,\rho_1);w) = 0;\quad I(\partial D(a,\rho_2);w) = I(\partial D(a,\rho_2);a) = 1
	\]
	Hence,
	\[
		f(w) = \frac{1}{2\pi i} \int_{\partial D(a,\rho_2)} \frac{f(z) \dd{z}}{z-w} - \frac{1}{2\pi i}\int_{\partial D(a,\rho_1)} \frac{f(z) \dd{z}}{z-w}
	\]
	This is an analogue of Cauchy's integral formula for annular domains.
	We can now proceed as before when proving the Taylor series expansion for holomorphic functions.

	For the first integral, consider the expansion
	\[
		\frac{1}{z-w} = \frac{1}{z-a-(w-a)} = \sum_{n=0}^\infty \frac{(w-a)^n}{(z-a)^{n+1}}
	\]
	This series converges uniformly over \( z \in \partial D(a,\rho_2) \), since \( \abs{\frac{w-a}{z-a}} < 1 \).
	For the second integral, consider
	\[
		\frac{1}{z-w} = \frac{1}{z-a-(w-a)} = -\frac{1}{(w-a)\qty(1-\frac{z-a}{w-a})} = -\sum_{n=0}^\infty \frac{(z-a)^n}{(w-a)^{n+1}}
	\]
	Likewise, this series converges uniformly over \( z \in \partial D(a,\rho_1) \), since \( \abs{\frac{z-a}{w-a}} < 1 \) in this disc.
	Substituting these into the representation formula, we can switch integration and summation due to uniform convergence.
	This gives
	\[
		f(w) = \sum_{n=0}^\infty c_n (w-a)^n + \sum_{n=1}^\infty c_{-n} (w-a)^{-n}
	\]
	where
	\[
		c_n = \frac{1}{2\pi i} \int_{\partial D(a,\rho_2)} \frac{f(z) \dd{z}}{(z-a)^{n+1}}
	\]
	for \( n \geq 0 \), and
	\[
		c_n = \frac{1}{2\pi i} \int_{\partial D(a,\rho_1)} \frac{f(z) \dd{z}}{(z-a)^{n+1}}
	\]
	for \( n \leq -1 \).
	Since \( \partial D(a,\rho_1) \) and \( \partial D(a,\rho_2) \) are homotopic in \( A \) to \( \partial D(a,\rho) \) for any \( \rho \in (r,R) \), we have that
	\[
		c_n = \frac{1}{2\pi i} \int_{\partial D(a,\rho)} \frac{f(z) \dd{z}}{z-a}
	\]
	for any \( \rho \in (r,R) \) and \( n \in \mathbb Z \), so (i) and the formula (ii) both hold.

	To show (iii) and uniqueness, suppose there exist constants \( c_n \) such that, for all \( z \in A \), we have
	\begin{equation}
		f(z) = \sum_{n=-\infty}^\infty c_n (z-a)^n \tag{\(\ast\)}
	\end{equation}
	Let \( r < \rho' \leq \rho < R \).
	Then the power series \( \sum_{n=0}^\infty c_n (z-a)^n \) converges for \( z \in A \), so it has radius of convergence at least \( R \), and converges uniformly for \( \abs{z-a} \leq \rho \).
	Further, the series \( \sum_{n=1}^\infty c_{-n} (z-a)^{-n} \) converges on \( A \).
	Let \( \zeta = (z-a)^{-1} \).
	Then the power series \( \sum_{n=1}^\infty c_{-n} \zeta^n \) converges for \( \frac{1}{R} < \abs{\zeta} < \frac{1}{r} \) so it has radius of convergence at least \( \frac{1}{r} \) and converges uniformly for \( \abs{\zeta} \leq \frac{1}{\rho'} \).
	Thus, the series \( \sum_{n=1}^\infty c_{-n} (z-a)^{-n} \) converges uniformly for \( \abs{z-a} \geq \rho' \).
	Hence (\(\ast\)) converges uniformly in \( \rho' \leq \abs{z-a} \leq \rho \).
	Hence, for any \( m \in \mathbb Z \), we have
	\[
		\int_{\partial D(a,\rho)} \frac{f(z) \dd{z}}{(z-a)^{m+1}} = \sum_{n=-\infty}^\infty c_n \int_{\partial D(a,\rho)} (z-a)^{n-m-1} \dd{z}
	\]
	By the fundamental theorem of calculus, the only nonzero integral on the right hand side occurs when \( n - m - 1 = -1 \), which occurs for \( n = m \) only.
	This integral gives
	\[
		c_m = \frac{1}{2\pi i} \int_{\partial D(a,\rho)} \frac{f(z) \dd{z}}{(z-a)^{m+1}}
	\]
	for all \( \rho \in (r,R) \).
	This formula also implies the uniqueness of the \( c_n \) for which the series expansion is valid.
\end{proof}
\begin{remark}
	The above proof shows that if \( f \colon A \equiv D(a,R)\setminus \overline{D(a,r)} \to \mathbb C \) is holomorphic, then there is a holomorphic function \( f_1 \colon D(a,R) \to \mathbb C \) and a holomorphic function \( f_2 \colon \mathbb C \setminus \overline{D(a,r)} \to \mathbb C \) such that \( f = f_1 + f_2 \) on \( A \).
	This decomposition is not unique, since we can take \( f_1 \mapsto f_1 + g \) and \( f_2 \mapsto f_2 - g \) for an entire function \( g \).
	However, if we also require \( f_2(z) \to 0 \) as \( z \to \infty \), the decomposition into two series given in (ii) above is unique.
\end{remark}

\subsection{Coefficients of Laurent series}
Let \( f \colon D(a,R) \setminus \qty{a} \to \mathbb C \) be holomorphic, so \( z = a \) is an isolated singularity of \( f \).
Then, by the Laurent series with \( r = 0 \), we have a unique set of complex numbers \( c_n \) such that
\[
	f(z) = \sum_{n=-\infty}^\infty c_n (z-a)^n
\]
Then,
\begin{enumerate}
	\item If \( c_n = 0 \) for all \( n < 0 \), we have \( f(z) = \sum_{n=0}^\infty c_n (z-a)^n \equiv g(z) \) on \( D(a,R) \setminus \qty{a} \).
	      Since \( g \) is holomorphic on \( D(a,R) \), \( z = a \) is a removable singularity.
	\item If \( c_{-k} \neq 0 \) for some \( k \geq 1 \) and \( c_{-n} = 0 \) for all \( n \geq k + 1 \), we have
	      \[
		      f(z) = \frac{c_{-k}}{(z-a)^k} + \frac{c_{-k+1}}{(z-a)^{k+1}} + \dots + \frac{c_{-1}}{z-a} + \sum_{n=0}^\infty c_n (z-a)^n
	      \]
	      Hence, \( f(z) = (z-a)^{-k} g(z) \) for a function \( g \) which is holomorphic on \( D(a,R) \), and where \( g(a) = c_{-k} \neq 0 \).
	      Equivalently, \( z = a \) is a pole of order \( k \).
	\item If \( c_n \neq 0 \) for infinitely many \( n < 0 \), \( z = a \) is an essential singularity.
	      This holds since the above two parts were all bidirectional implications.
\end{enumerate}

\subsection{Residues}
\begin{definition}
	Let \( f \colon D(a,R) \setminus \qty{a} \to \mathbb C \) be holomorphic.
	The coefficient \( c_{-1} \) of the Laurent series of \( f \) in \( D(a,R) \setminus \qty{a} \) is called the \textit{residue of \( f \) at \( a \)}, denoted \( \Res_f(a) \).
	The series
	\[
		f_P = \sum_{n=1}^\infty c_{-n} (z-a)^{-n}
	\]
	is known as the \textit{principal part of \( f \) at \( a \)}.
\end{definition}
We know that \( f_P \) is holomorphic on \( \mathbb C \setminus \qty{a} \), with the series defining \( f_P \) converging uniformly on compact subsets of \( \mathbb C \setminus \qty{a} \).
By the Laurent series, \( f = f_P + h \) on \( D(a,R) \setminus \qty{a} \), where \( h \) is holomorphic on \( D(a,R) \).
Let \( \gamma \) be a closed curve in \( D(a,R) \) with \( a \not\in \Im \gamma \).
Then \( \int_\gamma h(z) \dd{z} = 0 \) by Cauchy's theorem, and hence \( \int_\gamma f(z) \dd{z} = \int_\gamma f_P(z) \dd{z} = 2\pi i \cdot I(\gamma;a) \Res_f(a) \), where the last inequality holds by uniform convergence of the series for \( f_P \) and the fundamental theorem of calculus.
This reasoning can be extended to the case of more then one isolated singularity.
\begin{theorem}[residue theorem]
	Let \( U \) be an open set, \( \qty{a_1, \dots, a_k} \subset U \) be finite, and \( f \colon U \setminus \qty{a_1, \dots, a_k} \to \mathbb C \) be holomorphic.
	If \( \gamma \) is a closed curve in \( U \) homologous to zero in \( U \), and if \( a_j \not\in \Im \gamma \) for each \( j \), then
	\[
		\frac{1}{2\pi i} \int_\gamma f(z) \dd{z} = \sum_{j=1}^k I(\gamma;a_j) \Res_f(a_j)
	\]
\end{theorem}
This is a generalisation of Cauchy's integral formula.
\begin{proof}
	Let \( f_P^{(j)} = \sum_{n=1}^\infty c_{-n}^{(j)} (z-a_j)^{-n} \) be the principal part of \( f \) at \( a_j \).
	Then \( f_P^{(j)} \) is holomorphic in \( \mathbb C \setminus \qty{a_j} \), and hence is holomorphic in \( \mathbb C \setminus \qty{a_1, \dots, a_k} \).
	Let
	\[
		h \equiv f - \qty(f_P^{(1)} + \dots + f_P^{(k)})
	\]
	This \( h \) is holomorphic in \( U \setminus \qty{a_1, \dots, a_k} \).
	Let \( j \) be fixed.
	Then \( f - f_P^{(j)} \) has a removable singularity at \( z = a_j \).
	For all \( \ell \neq j \), \( f_P^{(\ell)} \) is holomorphic at \( a_j \).
	Hence \( h \) has a removable singularity at \( a_j \).
	This is true for all \( j \), so \( h \) extends to all of \( U \) as a holomorphic function.
	By Cauchy's theorem, \( \int_\gamma h(z) \dd{z} = 0 \).
	Hence
	\[
		\frac{1}{2\pi i} \int_\gamma f(z) \dd{z} = \sum_{j=1}^k \frac{1}{2\pi i} \int_\gamma f_P^{(j)}(z) \dd{z}
	\]
	By termwise integration of the series for \( f_P^{(j)} \), which converges uniformly on compact subsets of \( \mathbb C \setminus \qty{a_j} \), we have
	\[
		\frac{1}{2\pi i} \int_\gamma f_P^{(j)}(z) \dd{z} = I(\gamma;a_j) \Res_f(a_j)
	\]
	as required.
\end{proof}
There are simple ways to calculate residues if we know information about the singularity in question.
\begin{enumerate}
	\item If \( f \) has a simple pole at \( z = a \), then
	      \[
		      \Res_f(a) = \lim_{z \to a} (z-a) f(z)
	      \]
	      Indeed, near \( a \), we have \( f(z) = (z-a)^{-1} g(z) \) where \( g \) is holomorphic and \( g(a) \neq 0 \).
	      Hence, by the Taylor expansion of \( g \), we have that \( \Res_f(a) = g(a) \).
	\item If \( f \) has a pole of order \( k \) at \( a \), then near \( a \) we have that \( f(z) = (z-a)^{-k} g(z) \) where \( g \) is holomorphic and \( g(a) \neq 0 \).
	      In this case, the residue \( \Res_f(a) \) is the coefficient of the \( (z-a)^{k-1} \) term of the Taylor series of \( g \) at \( a \), which is
	      \[
		      \Res_f(a) = \frac{g^{(k-1)}(a)}{(k-1)!}
	      \]
	\item If \( f = \frac{g}{h} \) where \( g \) and \( h \) are holomorphic at \( z = a \), such that \( g(a) \neq 0 \) and \( h \) has a simple zero at \( z = a \), then from (i) we have
	      \[
		      \Res_f(a) = \lim_{z \to a} \frac{(z-a)g(z)}{h(z)} = \lim_{z \to a} \frac{g(z)}{\frac{h(z) - h(a)}{z-a}} = \frac{g(a)}{h'(a)}
	      \]
\end{enumerate}
\begin{example}
	For \( 0 < \alpha < 1 \), we will show that
	\[
		\int_0^\infty \frac{x^{-\alpha}}{1+x} \dd{x} = \frac{\pi}{\sin \pi \alpha}
	\]
	Let \( g(z) = z^{-\alpha} \) be the branch of \( z^{-\alpha} \) defined by \( g(z) = e^{-\alpha \ell(z)} \), where \( \ell(z) \) is the holomorphic branch of logarithm on \( U = \mathbb C \setminus \qty{x \in \mathbb R \colon x \geq 0} \).
	given by \( \ell(z) = \log \abs{z} + i \arg z \) where \( \arg(z) \) takes values in \( (0,2\pi) \).
	Let \( f(z) = \frac{g(z)}{1+z} \).
	Then
	\[
		f(z) = \frac{\abs{z}^{-\alpha} e^{-i\alpha \arg z}}{1+z}
	\]
	and \( f \) is holomorphic in \( U \setminus \qty{-1} \) where \( z = -1 \) is a simple pole with \( \Res_f(-1) = \lim_{z \to -1}(z+1)f(z) = e^{-i\pi \alpha} \).

	Let \( \varepsilon, R \) be such that \( 0 < \varepsilon < 1 < R \) and \( \theta > 0 \) be small.
	Let \( \gamma \) be the positively-oriented `keyhole countour' determined by the two circular arcs \( \gamma_R \colon [\theta,2\pi-\theta] \to U \) and the two line segments \( \gamma_1, \gamma_2 \colon [\varepsilon, R] \to U \) given by
	\[
		\gamma_R(t) = Re^{it};\quad \gamma_\varepsilon(t) = \varepsilon e^{i(2\pi - t)};\quad \gamma_1(t) = te^{i\theta};\quad \gamma_2(t) = te^{i(2\pi - \theta)}
	\]
	The domain \( U \) is star shaped and hence simply connected, and so \( \gamma \) is homologous to zero in \( U \).
	Directly from the definitions of \( \gamma \) and the winding number, we can show that \( I(\gamma; -1) = 1 \).

	By the residue theorem, we find \( \int_\gamma f(z) \dd{z} = 2\pi i e^{-i\pi \alpha} \).
	Now,
	\[
		\int_{\gamma_1} f(z) \dd{z} = \int_\varepsilon^R f(te^{i\theta}) e^{i\theta} \dd{t} = \int_\varepsilon^R \frac{t^{-\alpha} e^{i(1-\alpha)\theta}}{1+te^{i\theta}} \dd{t}
	\]
	and
	\[
		\int_{\gamma_2} f(z) \dd{z} = \int_\varepsilon^R f(te^{i(2\pi - \theta)}) e^{i(2\pi - \theta)} \dd{t} = \int_\varepsilon^R \frac{t^{-\alpha} e^{i(1-\alpha)(2\pi - \theta)}}{1 + te^{i(2\pi - \theta)}} \dd{t}
	\]
	As \( \theta \to 0^+ \), we can show that the integrands converge uniformly on \( [\varepsilon, R] \) to \( \frac{t^{-\alpha}}{1+t} \) and \( \frac{e^{-2i\pi \alpha}t^{-\alpha}}{1+t} \) respectively.
	Hence,
	\[
		\lim_{\theta \to 0^+} \qty[ \int_{\gamma_1} f(z) \dd{z} + \int_{(-\gamma_2)} f(z) \dd{z} ] = \qty(1 - e^{-2i\pi \alpha}) \int_\varepsilon^R \frac{t^{-\alpha}}{1+t} \dd{t}
	\]
	For all \( z \in \Im \gamma_R \), we have \( \abs{f(z)} \leq \frac{R^{-\alpha}}{R-1} \); and for all \( z \in \Im \gamma_\varepsilon \), we have \( \abs{f(z)} \leq \frac{\varepsilon^{-\alpha}}{1-\varepsilon} \).
	Hence,
	\[
		\abs{\int_{\gamma_R} f(z) \dd{z} + \int_{\gamma_\varepsilon} f(z) \dd{z}} \leq \frac{2\pi R^{1-\alpha}}{R - 1} + \frac{2\pi \varepsilon^{1-\alpha}}{1-\varepsilon}
	\]
	Note that the right hand side is independent of \( \theta \), even though \( \gamma_R \) and \( \gamma_\varepsilon \) depend on \( \theta \).
	Since
	\[
		\int_\gamma f(z) \dd{z} - \qty(\int_{\gamma_1} f(z) \dd{z} + \int_{(-\gamma_2)} f(z) \dd{z}) = \int_{\gamma_R} f(z) \dd{z} + \int_{\gamma_\varepsilon} f(z) \dd{z}
	\]
	we then have that
	\[
		\abs{2\pi i e^{-i\pi \alpha} - \qty(\int_{\gamma_1} f(z) \dd{z} + \int_{(-\gamma_2)} f(z) \dd{z}) } \leq \frac{2\pi R^{1-\alpha}}{R-1} + \frac{2\pi \varepsilon^{1-\alpha}}{1-\varepsilon}
	\]
	First letting \( \theta \to 0^+ \) in this, and then letting \( \varepsilon \to 0^+ \) and \( R \to \infty \), we conclude
	\[
		\qty(1-e^{-2\pi i \alpha}) \int_0^\infty \frac{t^{-\alpha}}{1+t} \dd{t} = 2\pi i e^{-i\pi\alpha}
	\]
	or,
	\[
		\int_0^\infty \frac{t^{-\alpha}}{1+t} \dd{t} = \frac{\pi}{\sin \pi \alpha}
	\]
\end{example}

\subsection{Jordan's lemma}
\begin{lemma}
	Let \( f \) be a continuous complex-valued function on the semicircle \( C_R^+ = \Im \gamma_R^+ \) in the upper half-plane, where \( R > 0 \) and \( \gamma_R^+(t) = Re^{it} \) for \( 0 \leq t \leq \pi \).
	Then, for \( \alpha > 0 \),
	\[
		\abs{\int_{\gamma_R^+} f(z) e^{i\alpha z} \dd{z}} \leq \frac{\pi}{\alpha} \sup_{z \in C_R^+} \abs{f(z)}
	\]
	In particular, if \( f \) is continuous in \( H^+ \setminus D(0,R_0) \) for \( R_0 > 0 \) where \( H^+ = \qty{z \colon \Im z \geq 0} \) and if \( \sup_{z \in C_R^+} \abs{f(z)} \to 0 \) as \( R \to \infty \), then for each \( \alpha > 0 \), we have
	\[
		\int_{\gamma_R^+} f(z) e^{i\alpha z} \dd{z} \to 0
	\]
	as \( R \to \infty \).
\end{lemma}
A similar statement holds for \( \alpha < 0 \) and the semicircle \( C_R^- = \Im \gamma_R^- \) in the lower half-plane where \( \gamma_R^-(t) = -Re^{it} \) for \( R > 0 \) and \( 0 \leq t \leq \pi \).
\begin{proof}
	Let \( M_R = \sup_{z \in C_R^+} \abs{f(z)} \).
	Then,
	\begin{align*}
		\abs{\int_{\gamma_R^+} f(z) e^{i\alpha z} \dd{z}} & = \abs{\int_0^\pi f(Re^{it}) e^{-\alpha R \sin t + i\alpha R \cos t}iRe^{it} \dd{t}}                                     \\
		                                                  & \leq RM_R \int_0^\pi e^{-\alpha R \sin t} \dd{t}                                                                         \\
		                                                  & = RM_R \qty( \int_0^{\frac{\pi}{2}} e^{-\alpha R \sin t} \dd{t} + \int_{\frac{\pi}{2}}^\pi e^{-\alpha R \sin t} \dd{t} ) \\
		                                                  & = 2RM_R \int_0^{\frac{\pi}{2}} e^{-\alpha R \sin t} \dd{t}                                                               \\
		                                                  & \leq 2 RM_R \int_0^{\frac{\pi}{2}} e^{\frac{-2\alpha R t}{\pi}} \dd{t}                                                   \\
		                                                  & = \frac{\pi M_R}{\alpha} \qty(1 - e^{-\alpha R}) \leq \frac{\pi M_R}{\alpha}
	\end{align*}
	where we have used the fact that for \( t \in (0,\frac{\pi}{2}] \), \( \varphi(t) \equiv \frac{\sin t}{t} \geq \frac{2}{\pi} \) since \( \varphi(\frac{\pi}{2}) = \frac{2}{\pi} \) and \( \varphi'(t) \leq 0 \) on \( [0,\frac{\pi}{2}] \).
\end{proof}
\begin{lemma}[integrals on small circular arcs]
	Let \( f \) be holomorphic in \( D(a,R) \setminus \qty{a} \) with a simple pole at \( z = a \).
	Let \( \gamma_\varepsilon \colon [\alpha,\beta] \to \mathbb C \) be the circular arc \( \gamma_\varepsilon(t) = a + \varepsilon e^{it} \).
	Then
	\[
		\lim_{\varepsilon \to 0^+} \int_{\gamma_\varepsilon} f(z) \dd{z} = (\beta - \alpha) i \Res_f(a)
	\]
\end{lemma}
\begin{proof}
	Let \( f(z) = \frac{c}{z-a} + g(z) \) where \( g \) is holomorphic in \( D(a,R) \) and \( c = \Res_f(a) \).
	Then
	\[
		\abs{\int_{\gamma_\varepsilon} g(z) \dd{z}} = \abs{\int_\alpha^\beta g(a+\varepsilon e^{it}) \varepsilon i e^{it}} \leq \varepsilon (\beta - \alpha) \sup_{t \in [\alpha,\beta]} \abs{g(a+\varepsilon e^{it})} \to 0
	\]
	as \( \varepsilon \to 0^+ \).
	By direct calculation,
	\[
		\int_{\gamma_\varepsilon} \frac{c}{z-a} \dd{z} = (\beta-\alpha)i\Res_f(a)
	\]
	Hence the claim follows.
\end{proof}
\begin{example}
	Consider \( \int_0^\infty \frac{\sin x}{x} \dd{x} \).
	Let \( f(z) = \frac{e^{iz}}{z} \).
	Consider the integral \( \int_\gamma f(z) \dd{z} \) over the curve \( \gamma = \gamma_R + \gamma_1 + \gamma_\varepsilon + \gamma_2 \) where
	\begin{enumerate}
		\item \( \gamma_R(t) = Re^{it} \) for \( 0 \leq t \leq \pi \);
		\item \( \gamma_1(t) = t \) for \( -R \leq t \leq -\varepsilon \);
		\item \( \gamma_\varepsilon(t) = \varepsilon e^{-it} \) for \( -\pi \leq t \leq 0 \);
		\item \( \gamma_2(t) = t \) for \( \varepsilon \leq t \leq R \).
	\end{enumerate}
	By Jordan's lemma, \( \int_{\gamma_R} f(z) \dd{z} \to 0 \) as \( R \to \infty \).
	\( f \) has a simple pole at \( z = 0 \) with \( \Res_f(0) = \lim_{z \to 0} z f(z) = 1 \).
	By the above lemma, \( \int_{-\gamma_\varepsilon} f(z) \dd{z} \to \pi i \) as \( \varepsilon \to 0^+ \).

	Since \( f \) is holomorphic in \( U = \mathbb C \setminus \qty{0} \) and \( \gamma \) is homologous to zero in \( U \), Cauchy's theorem gives that
	\[
		\int_\gamma f(z) \dd{z} = 0 \implies \int_{\gamma_R} f(z) \dd{z} + \int_{-R}^{-\varepsilon} \frac{e^{it}}{t} \dd{t} + \int_{\gamma_\varepsilon} f(z) \dd{z} + \int_{\varepsilon}^R \frac{e^{it}}{t} \dd{t} = 0
	\]
	Combining the two integrals on the real axis under a change of variables,
	\[
		\int_{\varepsilon}^R \frac{e^{it} - e^{-it}}{t} \dd{t} + \int_{\gamma_R} f(z) \dd{z} + \int_{\gamma_{\varepsilon}} f(z) \dd{z} = 0
	\]
	Letting \( R \to \infty \) and \( \varepsilon \to 0^+ \), we have
	\[
		\int_0^\infty \frac{\sin t}{t} \dd{t} = \frac{\pi}{2}
	\]
\end{example}
\begin{example}
	We prove that \( \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6} \).
	Consider the function
	\[
		f(z) = \frac{\pi \cot(\pi z)}{z^2} = \frac{\pi \cos(\pi z)}{z^2 \sin(\pi z)}
	\]
	This is holomorphic in \( \mathbb C \) except for simple poles at each point in \( \mathbb Z \setminus \qty{0} \), and an order 3 pole at zero.
	Near \( n \in \mathbb Z \setminus \qty{0} \), we have \( f(z) = \frac{g(z)}{h(z)} \) where \( g(n) \neq 0 \) and \( h \) has a simple zero at \( n \), and so
	\[
		\Res_f(n) = \frac{g(n)}{h'(n)} = \frac{1}{n^2}
	\]
	To compute the residue at zero, consider
	\[
		\cot z = \frac{\cos z}{\sin z} = \qty(1 - \frac{z^2}{2} + O(z^4)) \qty(z - \frac{z^3}{6} + O(z^5))^{-1} = \frac{1}{z} - \frac{z}{3} + O(z^2)
	\]
	Hence,
	\[
		\frac{\pi \cot(\pi z)}{z^2} = \frac{1}{z^3} - \frac{\pi^2}{3z} + \dots
	\]
	This shows that \( \Res_f(0) = -\frac{\pi^2}{3} \).
	For \( N \in \mathbb N \), let \( \gamma_N \) be the positively oriented boundary of the square defined by the lines \( x = \pm (N + \frac{1}{2}) \) and \( y = \pm (N + \frac{1}{2}) \).
	By the residue theorem,
	\begin{equation}
		\int_{\gamma_N} f(z) \dd{z} = 2\pi i \qty[2\qty(\sum_{n=1}^N \frac{1}{n^2}) - \frac{\pi^2}{3}] \tag{\(\ast\)}
	\end{equation}
	Since \( \mathrm{length}(\gamma_N) = 4(2N + 1) \), we have
	\begin{align*}
		\abs{\int_{\gamma_N} f(z) \dd{z}} & \leq \sup_{\gamma_N} \abs{\frac{\pi \cot(\pi z)}{z^2}} \cdot 4(2N + 1)              \\
		                                  & \leq \sup_{\gamma_N} \abs{\cot(\pi z)} \cdot \frac{4(2N + 1)\pi}{(N+\frac{1}{2})^2} \\
		                                  & = \frac{16 \pi}{2N+1} \cdot \sup_{\gamma_N} \abs{\cot(\pi z)}
	\end{align*}
	On \( \gamma_N \), it is possible to show that \( \cot(\pi z) \) is bounded independently of \( N \).
	Hence,
	\[
		\int_{\gamma_N} f(z) \dd{z} \to 0
	\]
	as \( N \to \infty \).
	Letting \( N \to \infty \) in (\(\ast\)), we find
	\[
		\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}
	\]
\end{example}
